﻿@using DCMS.Core.Domain.Common;
@using DCMS.ViewModel.Models.Sales;

@model ReturnReservationBillModel
@*打印区域*@
<div id="printData"></div>
<input asp-for="Id" type="hidden" />
<input asp-for="TerminalId" type="hidden" />
<input asp-for="SumAmount" type="hidden" />
<input asp-for="BillTypeEnumId" type="hidden" />


@if (!ViewData.ModelState.IsValid)
{
    <div class="alert alert-warning alert-dismissable mt10">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
        <div asp-validation-summary="All"></div>
    </div>
}

@if (Model.AuditedStatus || Model.ReversedStatus)
{
    @await Html.PartialAsync("_Watermark")
}

<div class="row">

    <div class="col-lg-12">
        <div class="form-group mb10">

            <div class="col-sm-2">
                <div class="input-group">
                    <input asp-for="TerminalName" class="form-control" placeholder="客户..." readonly="@(Model.AuditedStatus?"readonly":"")" />

                    <span class="input-group-btn">
                        <button id="btn_search_customer" type="button" class="btn btn-default" @(Model.AuditedStatus ? "disabled" : "")>
                            <span class="glyphicon glyphicon-search"></span>
                        </button>
                    </span>
                </div>
            </div>
            <div class="col-sm-1">
                <dcms-select asp-for="BusinessUserId" asp-items="@Model.BusinessUsers" asp-default="业务员" class="form-control" asp-disabled="@(Model.AuditedStatus)" />
            </div>
            <div class="col-sm-1">
                <dcms-select asp-for="DeliveryUserId" asp-items="@Model.DeliveryUsers" asp-default="送货员" class="form-control" asp-disabled="@(Model.AuditedStatus)" />
            </div>
            <div class="col-sm-1">
                <dcms-select asp-for="WareHouseId" asp-items="@Model.WareHouses" asp-default="仓库" class="form-control" asp-disabled="@(Model.AuditedStatus)" />
            </div>
            <div class="col-sm-1">
                <dcms-select asp-for="PayTypeId" asp-items="@Html.GetEnumSelectList<ReturnReservationBillPayType>().ToSelectListDescription<ReturnReservationBillPayType>()" asp-default="请选择" asp-disabled="@(Model.AuditedStatus)" />
            </div>
            <div class="col-sm-2">
                <dcms-editor asp-for="TransactionDate" placeholder="交易日期..." asp-disabled="@(Model.AuditedStatus)" />
            </div>
            <div class="col-sm-1">
                <dcms-select-bool asp-for="IsMinUnitSale" asp-items="@(new string[] {  "是", "否"})" asp-default="按最小单位销售" asp-disabled="@(Model.AuditedStatus)" />
            </div>
            <div class="col-sm-2">
                <dcms-input asp-for="Remark" class="form-control" placeholder="备注..." asp-readonly="@(Model.AuditedStatus)" />
            </div>
            <div class="col-sm-1">
                <dcms-select asp-for="DefaultAmountId" asp-items="@Model.ReturnReservationDefaultAmounts" class="form-control" asp-disabled="@(Model.AuditedStatus)" asp-default="选择价格体系" />
            </div>

        </div>
    </div>
</div>

<div class="row" style="color:deepskyblue">
    <div class="col-md-12">
        <span class="pull-left mt10 TBalance_Box" style="display:none">剩余预收款金额：</span>
        <span class="pull-left TBalance_Box mr10" style="display:none">
            <input asp-for="TBalance.AdvanceAmountBalance" style="color:deepskyblue" class="form-control-bb input-sm pbn pln prn" readonly="readonly" />
        </span>
        <span class="pull-left mt10 TBalance_Box" style="display:none">终端欠款：</span>
        <span class="pull-left TBalance_Box mr10" style="display:none">
            <input asp-for="TBalance.TotalOweCash" style="color:deepskyblue" class="form-control-bb input-sm pbn pln prn" readonly="readonly" />
        </span>

        <span class="pull-left mt10 UBalance_Box" style="display:none">业务员可用欠款：</span>
        <span class="pull-left UBalance_Box mr10" style="display:none">
            <input asp-for="UserAvailableAmount" style="color:deepskyblue" class="form-control-bb input-sm pbn pln prn" readonly="readonly" />
        </span>
        <span class="pull-left mt10  UBalance_Box" style="display:none">业务员已用欠款：</span>
        <span class="pull-left  UBalance_Box mr10" style="display:none">
            <input asp-for="UserUsedAmount" style="color:deepskyblue" class="form-control-bb input-sm pbn pln prn" readonly="readonly" />
        </span>
    </div>
</div>

<div class="row mtn mb10">
    <div class="col-md-3 ">
        <div class="form-group mbn">
            <lable class="col-lg-3 control-label">单据编号：</lable>
            <div class="col-lg-9">
                <input asp-for="BillNumber" class="form-control-bb input-sm pbn pln prn" readonly="readonly" />
            </div>
        </div>
    </div>
    <div class="col-md-3 ">
        <div class="form-group mbn">
            <lable class="col-lg-3 control-label">制单：</lable>
            <div class="col-lg-9">
                <input asp-for="MakeUserName" class="form-control-bb input-sm pbn pln prn" readonly="readonly" />
            </div>
        </div>
    </div>

    @if (Model.Id != 0 && !string.IsNullOrEmpty(@Model.BillBarCode))
    {
        <div class="col-md-3 ">
            <div class="form-group mbn">
                <lable class="col-lg-3 control-label">审核：</lable>
                <div class="col-lg-9">
                    <input asp-for="AuditedUserName" class="form-control-bb input-sm pbn pln prn" readonly="readonly" />
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <img class="media-object mn thumbnail pull-right" src="@Model.BillBarCode" />
        </div>
    }
</div>


<div class="row mt10 mb10">
    <div class="col-md-12">
        <table class="table table-striped table-bordered table-hover" id="ReturnReservationItems"></table>
    </div>
</div>

<div class="row mt20" id="ReturnReservationItems_Partial_Form">
    <div class="col-sm-12">
        <span class="pull-left control-label mr10">本次优惠金额:</span>
        <span class="pull-left">
            <dcms-input asp-for="PreferentialAmount" class="form-control-bb input-sm pbn pln prn" placeholder="本次优惠金额..." asp-readonly="@Model.AuditedStatus" />
        </span>

        <span class="pull-left control-label mr10">优惠后金额:</span>
        <span class="pull-left">
            <input asp-for="PreferentialEndAmount" class="form-control-bb input-sm pbn pln prn" placeholder="优惠后金额..." readonly="readonly" />
        </span>

        <!--//////////以下块为收款账户引用//////////-->
        <div id="CollectionAccountBox">
            @foreach (var acc in Model.ReturnReservationBillAccountings)
            {
                <span class="pull-left control-label mr10">@acc.Name:</span>
                <span class="pull-left">
                    <input class="form-control-bb input-sm pbn pln prn" data-val="true" id="CollectionAmount_@acc.AccountingOptionId" name="CollectionAmount" type="text" data-account="@acc.AccountingOptionId" value="@acc.CollectionAmount.ToString("0.00")" @(Model.AuditedStatus ? "readonly='readonly'" : "")>
                </span>
            }

        </div>

        <span class="pull-left mr10">
            <button id="Accounting_AsyncSearchSelectPopup" type="button" class="btn btn-default btn-sm" @((Model.AuditedStatus) || (Model.ReturnReservationBillAccountings.Count <= 0) ? "disabled" : "")>
                <span class="glyphicon glyphicon-check"></span> 更改预收款账户
            </button>
        </span>



        <span class="pull-left control-label mr10">待支付金额:</span>
        <span class="pull-left">
            <input asp-for="OweCash" class="form-control-bb input-sm pbn pln prn" placeholder="待支付金额..." readonly="readonly" />
        </span>
    </div>
</div>
